/**
 * Created by Administrator on 2015/5/25.
 */
angular.module('starter')
.controller('LoginController',function ($scope,$state,$ionicPopup,$ionicHistory,VoteService){
        $scope.loginModel={
            userName:''
        }
        $scope.enter= function(){
             $scope.loginForm.$setSubmitted();
            if($scope.loginForm.$valid){
                VoteService.setUserName($scope.loginModel.userName);
                console.log("userName:"+ VoteService.getUserName());
                $state.go('catalog');
                alert(VoteService.getUserName());
            }else{
                if($scope.loginForm.userName.$error.required){
                    VoteService.alertPopup('请录入姓名');
                }
            }

        }

        $ionicHistory.nextViewOptions({
            disableAnimate: true,
            disableBack: true,
            historyRoot:true
        });



    });